/* eslint valid-jsdoc: "off" */

"use strict";

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = (appInfo) => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = (exports = {});
  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + "_1620927537251_5175";

  // add your middleware config here
  config.middleware = ["errorHandler", "auth"];
  // 配置那些路由需要验证
  config.auth = {
    // ignore: ['/reg', '/login'],//不需要token验证的接口
    match: [//需要token验证的接口
      '/logout',
      "/upload",
      '/getUsers',
      '/getAllUsers',
      '/getUserOne',
      '/removeUser',
      '/updateUser',
      '/excelUser',
      '/setMenu',
      '/allMenuList',
      '/getMenuOne',
      '/updateMenuOne',
      '/removeMenu',
      '/setRole',
      '/allRoleList',
      '/getRoleOne',
      '/updateRoleOne',
      '/removeRole',
      '/getMenuByUserId',
    ],
  };

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
  config.security = {
    // 关闭 csrf
    csrf: {
      enable: false,
    },
    // 跨域白名单
    // domainWhiteList: [ 'http://localhost:3000' ],
  };
  // 允许跨域的方法
  config.cors = {
    origin: "*",
    allowMethods: "GET, PUT, POST, DELETE, PATCH",
  }; 
  config.sequelize = {
    
    dialect: "mysql", 
    username: "root",
    "password": "root",
    "database": "eggjs-demo",
    "host": "192.168.1.18",
     port: 3306,  
    timezone: "+08:00",
    define: {
      // 取消数据表名复数
      freezeTableName: true,
      // 自动写入时间戳 created_at updated_at deleted_at
      timestamps: true,
      // 是否逻辑删除
      paranoid: true,
      createdAt: "created_time",
      updatedAt: "updated_time",
      deletedAt: "deleted_time",
      // 所有驼峰命名格式化
      underscored: true,
    },
  };
  config.mysql = {
    client: {  
      host: '192.168.1.18', 
      port: '3306', 
      user: 'root', 
      password: 'root',  
      database: 'eggjs-demo',
      timezone:  '+08:00',
      dateStrings: 'DATETIME', // 返回形式
      debug: false, // 可以看sql日志
    },
  };
  config.valparams = {
    locale: "zh-cn",
    throwError: true,
  };
  config.crypto = {
    secret: "qhdgw@45ncashdaksh2!#@3nxjdas*_672",
  };
  config.jwt = {
    secret: "qhdgw@45ncashdaksh2!#@3nxjdas*_672",
  }; 
  config.redis = { client: { host: "127.0.0.1",port: 6379, password: "", db: 4, } };  
  config.multipart = {
    fileSize: '50mb',
    mode: 'stream',
    fileExtensions: ['.xls', '.txt', '.jpg', '.JPG', '.png', '.PNG', '.gif', '.GIF', '.jpeg', '.JPEG'], // 扩展几种上传的文件格式
  };

  return {
    ...config,
    ...userConfig,
  };
};
